"""
题目：输入某年某月某日，判断这一天是这一年的第几天？
"""


import re

# t1、t2是自己写的
# def t1():
#     year = int(input("nian: "))
#     month = int(input("yue: "))
#     day = int(input("ri: "))
#     # 列出当前月份的日期数字
#     days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
#     # 算 闰年，差一天
#     if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
#         total_sum = days[month-1]+day+1
#     else:
#         total_sum = days[month-1]+day
#     print(total_sum)


# t1()


# def t2(riqi_str):
#     # 正则拆分 2025年10月5日 获取年月日
#     pattern = r"(\d{4})年(\d{1,2})月(\d{1,2})日"
#     match = re.match(pattern, riqi_str)

#     if match:
#         year = int(match.group(1))
#         month = int(match.group(2))
#         day = int(match.group(3))
#         print(year, month, day)  # 输出: 2025 10 5
#     else:
#         print("日期格式不匹配")

#     days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
#     if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
#         total_sum = days[month-1]+day+1
#     else:
#         total_sum = days[month-1]+day
#     print(total_sum)


# t2("2025年10月5日")


def is_leap(year):
    """判断闰年"""
    return year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)

# t3 是 文心一言生成的


def t3():
    year = int(input("年: "))
    month = int(input("月: "))
    day = int(input("日: "))

    # 各月天数列表（平年），2月动态调整
    month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    if is_leap(year):
        month_days[1] = 29  # 闰年2月29天

    # 验证输入有效性
    if month < 1 or month > 12:
        print("月份无效！")
        return
    if day < 1 or day > month_days[month-1]:
        print("日期无效！")
        return

    # 计算总天数：前month-1个月的总天数 + 当月天数
    total_days = sum(month_days[:month-1]) + day
    print(f"{year}年{month}月{day}日是该年的第{total_days}天")


t3()
